Object.defineProperty(exports, "__esModule", {
  value: true
});
var def_VIVO_CreateBoxPortalAd = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this.OnShowCallback = new Map();
    this.OnDestroyCallback = new Map();
    this.OnHideCallback = new Map();
    this._nativecomplat = new Map();
    this.GamePortalAds = new Map();
    this.GamePortalAdsShow = new Map();
    this.isDestroy = true;
    this.isError = false;
    this.showing = -1;
  }
  return babel_createClass(_ctor, [{
    key: "Create",
    value: function Create(e, t) {
      var _this142 = this;
      console.log("VIVO_CreateBoxPortalAd开始创建:" + e);
      if (!this.GamePortalAds.has(e)) {
        if (window.qg.getSystemInfoSync().platformVersionCode >= 1076) {
          console.log("快应用平台版本号>=1076，支持互推盒子相关 API,开始创建" + e);
          var _n73 = window.qg.createBoxPortalAd({
            posId: e,
            image: "https://oppomini.eqmobi.com/stonesh/share/gengduoyouxi2.png",
            marginTop: 550
          });
          _n73.onLoad(function () {
            console.log("互推盒子九宫格广告加载成功");
            _this142.GamePortalAdsShow.get(e) && _this142.GamePortalAds.get(e).show();
          });
          _n73.onClose(function () {
            console.log("互推盒子九宫格广告关闭");
            console.log("call:", t);
            t && t();
          });
          _n73.onError(function (e) {
            console.log(e);
          });
          this.GamePortalAds.set(e, _n73);
        } else {
          console.log("快应用平台版本号低于1076，暂不支持互推盒子相关 API");
        }
      }
    }
  }, {
    key: "CreateAndShow",
    value: function CreateAndShow(e, t) {
      if (!(window.qg.getSystemInfoSync().platformVersionCode < 1090)) {
        this.Create(e, t);
        this.Show(e, t);
      }
    }
  }, {
    key: "Show",
    value: function Show(e, t) {
      this.GamePortalAds.has(e) || this.CreateAndShow(e, t);
      this.GamePortalAdsShow.set(e, true);
      this.GamePortalAds.get(e).show().then(function () {
        console.log("show success");
      }).catch(function (e) {
        console.log("show fail with:", e);
      });
      this.OnShowCallback.has(e) && this.OnShowCallback.get(e)();
    }
  }, {
    key: "hide",
    value: function hide(e) {
      this.GamePortalAdsShow.set(e, false);
      if (this.GamePortalAds.has(e)) {
        console.log("hide------------");
        this.GamePortalAds.get(e).hide();
      }
    }
  }, {
    key: "Destroy",
    value: function Destroy(e) {
      if (this.GamePortalAds.has(e)) {
        this.showing == e && (this.showing = -1);
        this.OnDestroyCallback.has(e) && this.OnDestroyCallback.get(e)();
        this.GamePortalAds.get(e).offLoad(function (e) {
          console.log(e);
        });
        this.GamePortalAds.get(e).offError(function (e) {
          console.log(e);
        });
        this.GamePortalAds.get(e).destroy().then(function () {
          console.log("destroy success");
        }).catch(function (e) {
          console.log("destroy fail with:" + e.errCode + "," + e.errMsg);
        });
        this.GamePortalAds.delete(e);
      }
    }
  }], [{
    key: "Instance",
    get() {
      _ctor._instance || (_ctor._instance = new _ctor());
      return _ctor._instance;
    }
  }]);
}();
exports.default = def_VIVO_CreateBoxPortalAd;